<?php
class MovieModel extends CI_Model {
	function __construct() { // call the Model constructor 
		parent::__construct (); // load database class and connect to MySQL
		$this->load->database ();
	}
	// fetch all rows 
	function fetchAllRows($table) {
		$query = $this->db->get ( $table );
		if ($query->num_rows () > 0) {
			// return result set as an associative array
			return $query->result_array ();
		}
	} // fetch rows based on a certain condition 
	

	function fetchRow($param, $field, $table) {
		
		$this->db->where ( $field, $param );
		$query = $this->db->get ( $table );
		//return result set as an associative array 
		return $query->result_array ();
	}
	// insert row 
	function insertRow($table, $data) {
		$this->db->insert ( $table, $data );
	}
	// get total number of rows 
	function getNumRows($table) {
		return $this->db->count_all ( $table );
	}
}
?>